<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: fyf
  Date: 2018/11/12
  Time: 9:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>${pageType}满意度调查分项</title>

  <jsp:include page="/common/basecss.jsp" flush="true"/>
  <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.js"></script>
  <script src="${pageContext.request.contextPath}/assets/js/layer-v3.1.0/layer/layer.js"></script>
</head>
<body>


<form action=""
      id="classForm" class="form-horizontal" method="post">

  <h5 class="page-header alert-info" style="padding:10px; margin:0px; margin-bottom:5px;">${pageType}满意度调查分项</h5>
  <div class="row">

    <div class="form-group">
      <label class="col-sm-3 control-label">调查分项id</label>
      <div class="col-sm-6">
        <input type="text" name="cid" readonly="readonly" class="form-control input-sm" placeholder="后台生成班级编号"/>
      </div>
    </div>

      <div class="form-group">
        <label class="col-sm-3 control-label">调查大项</label>
        <div class="col-sm-6">
          <select name="bigItemId" id="bigItemId">
            <c:forEach items="${bigItemList}" var="bigItem">
              <option value="${bigItem.id}">${bigItem.comment}</option>
            </c:forEach>
          </select>
        </div>
      </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">分项描述</label>
      <div class="col-sm-6">
        <textarea name="itemName" id="itemName" placeholder="请添加调查分项详细描述"></textarea>
      </div>
    </div>

    <h4 class="text-center">评分标准</h4>

    <div class="form-group">
      <label class="col-sm-3 control-label">很满意</label>
      <div class="col-sm-6">
        <input type="text" name="valueList" placeholder="填写数字评分">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">满意</label>
      <div class="col-sm-6">
        <input type="text" name="valueList" placeholder="填写数字评分">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">一般</label>
      <div class="col-sm-6">
        <input type="text" name="valueList" placeholder="填写数字评分">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">不满意</label>
      <div class="col-sm-6">
        <input type="text" name="valueList" placeholder="填写数字评分">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">很不满意</label>
      <div class="col-sm-6">
        <input type="text" name="valueList" placeholder="填写数字评分">
      </div>
    </div>


  </div>


  <div class="row">
    <div class="col-sm-6 col-sm-offset-3">
      <input  type="button" id="submitButton" class="btn btn-success" value="添加"/>

    </div>
  </div>
</form>

<script>
  $(function () {
      /*ajax提交，成功之后父级页面刷新*/
      /*$("#submitButton").click(function () {
          $("#classForm").submit();
          layer.load(1,{shade: false});
          setTimeout(function () {
              parent.location.reload();
          }, 2000);

      });*/
      $("#submitButton").click(function () {

          var params = "bigitemId=" + $('#bigItemId').val();
          params = params + '&' + "itemName=" + $("#itemName").val();
          var $inputs = $("input");

          for (var si in $inputs) {
              if ($inputs.eq(si).attr('name') != undefined){
                  params = params + '&' + $inputs.eq(si).attr('name') + '=' + $inputs.eq(si).val();
              }

          }


          $.ajax({
              type:'post',
              url:'${pageContext.request.contextPath}/admin/addSubItem.go',
              data:params,
              dataType:'json',
              success:function (resData) {
                  if (resData.state == 'OK'){
                      layer.msg('添加成功',{icon: 1});
                      setTimeout(function () {
                          parent.location.reload();
                      },1000);

                  } else {
                      layer.msg('添加失败',{icon: 2});
                  }
              },
              error:function () {

              }
          });
      });




  });


</script>




<jsp:include page="/common/basejs.jsp" flush="true"/>
</body>
</html>
